package it.nard.controller;

import it.nard.listener.ControlDocumentListener;
import it.nard.persistence.dao.AllevatoriMapper;
import it.nard.persistence.dao.LatteinentrataMapper;
import it.nard.persistence.dao.LatteinuscitaMapper;
import it.nard.persistence.dao.RmozzarellaMapper;
import it.nard.persistence.model.Allevatori;
import it.nard.persistence.model.AllevatoriExample;
import it.nard.persistence.model.Latteinentrata;
import it.nard.persistence.model.LatteinentrataExample;
import it.nard.persistence.model.Latteingiacenza;
import it.nard.persistence.model.Latteinuscita;
import it.nard.persistence.model.LatteinuscitaExample;
import it.nard.persistence.model.Rmozzarella;
import it.nard.persistence.model.RmozzarellaExample;
import it.nard.sourceframes.AllevatoriPnl;
import it.nard.sourceframes.LatteInEntrataPnl;
import it.nard.sourceframes.LatteInGiacenzaPnl;
import it.nard.sourceframes.LatteInUscitaPnl;
import it.nard.sourceframes.MainFrame;
import it.nard.sourceframes.RMozzarellaPnl;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;

import org.apache.ibatis.session.SqlSession;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlighterFactory;

public class RMozzarellaController  extends BasicController{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6729316031073309352L;



	public static final String R_MOZZARELLA = "mozzarella";
	
	
	


	
	public RMozzarellaController(){
		super("Rintr. Mozzarella", null);
	
	}
	
	
	
	
	public void select (MouseEvent mevent){
		
		try{
			this.selectedRow =  ((RMozzarellaPnl)controlPnl).getJTable0().convertRowIndexToModel( ((RMozzarellaPnl)controlPnl).getJTable0().getSelectedRow());
		}catch(Exception e ){
			
		}
		if(this.selectedRow==-1){
			return;
		}
		Rmozzarella rmozzarella = (Rmozzarella) objList.get(selectedRow);
		mainFrame.sendMessage("Selezionata Mozzarella Prodotta.", MainFrame.OK_MESSAGE);
		
		this.fromBean(rmozzarella);
		
		
	}
	public void onDateSelect(){
		DefaultTableModel dtm = (DefaultTableModel) ((RMozzarellaPnl)controlPnl).getJTable0().getModel();
		dtm.getDataVector().removeAllElements();
		dtm.setNumRows(0);
		dtm.fireTableDataChanged();
		
		
		Integer dataStart = null;
		Integer dataStop = null;
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
		
		try{
			String tempStart = sdf.format( ((RMozzarellaPnl)controlPnl).getJXDatePicker2().getDate());
			tempStart = tempStart.concat("01");
			
			dataStart = new Integer(tempStart);
			
			String tempStop = sdf.format( ((RMozzarellaPnl)controlPnl).getJXDatePicker2().getDate());
			tempStop = tempStop.concat("31");
			
			dataStop = new Integer(tempStop);
			
			
			
		}catch(Exception e ){
			e.printStackTrace();
		}
		
		RmozzarellaExample rme = new RmozzarellaExample();
		
		rme.createCriteria().andDataproduzioneBetween(dataStart, dataStop);
		rme.setOrderByClause("dataProduzione");
		
		SqlSession sqlSession = MainController.getSqlSessionFactory().openSession();
		
		objList = sqlSession.getMapper(RmozzarellaMapper.class).selectByExample(rme);
		mainFrame.sendMessage("Selezionata Mozzarella Prodotta.", MainFrame.OK_MESSAGE);
		
		sqlSession.close();
		
		dtm = (DefaultTableModel) ((RMozzarellaPnl)controlPnl).getJTable0().getModel();
		Iterator<Rmozzarella> iter = (Iterator<Rmozzarella>)objList.iterator();
		while(iter.hasNext()){
			Rmozzarella rMozzarella = iter.next();
			String data4Table = "";
			try{
				SimpleDateFormat sdf4View = new SimpleDateFormat("dd/MM/yyyy");
				data4Table = sdf4View.format(SDF_4_DB.parse(rMozzarella.getDataproduzione().toString()));
			}catch(Exception e ){
				
			}
			
			String totale = "";
			Double serb1 = 0d;
			try{

			serb1 = Double.valueOf(rMozzarella.getSerb1());
			
			}catch(Exception e ){} 
			
			Double serb2 = 0d;
			try{
				serb2 = Double.valueOf(rMozzarella.getSerb2());
				
			}catch(Exception e ){} 
			
			Double serb3 = 0d;
			try{
				serb3 = Double.valueOf(rMozzarella.getSerb3());
				
			}catch(Exception e ){} 
			
			Double serb4 = 0d;
			try{
				serb4 = Double.valueOf(rMozzarella.getSerb4());
				
			}catch(Exception e ){} 
			
			Double totaleD = 0d;
	
			try{
				totaleD = serb1+serb2+serb3+serb4;
				totale = totaleD.toString();
			}catch(Exception e ){} 
			
			dtm.addRow(new String[]{data4Table, totale});
		}
	
		
	
	}
	
	public List<Rmozzarella> retriveListFromDates(Date dt1, Date dt2){
		List<Rmozzarella> outList = null;
		Integer dataStart = null;
		Integer dataStop = null;
		try{
			String tempStart = SDF_4_DB.format( dt1);
			
			dataStart = new Integer(tempStart);
			
			String tempStop = SDF_4_DB.format( dt2);
			
			dataStop = new Integer(tempStop);		
		}catch(Exception e ){
			e.printStackTrace();
		}
		
		RmozzarellaExample rme = new RmozzarellaExample();
		
		rme.createCriteria().andDataproduzioneBetween(dataStart, dataStop);
		rme.setOrderByClause("dataProduzione");
		
		SqlSession sqlSession = MainController.getSqlSessionFactory().openSession();
		
		outList = sqlSession.getMapper(RmozzarellaMapper.class).selectByExample(rme);
		
		sqlSession.close();
		return outList;
	}
	
	
	public void delete (){
		
		SqlSession sqlSession = MainController.getSqlSessionFactory().openSession();
		
		sqlSession.getMapper(RmozzarellaMapper.class).deleteByPrimaryKey(((Rmozzarella)(objList.get(selectedRow))).getId());
	
		sqlSession.commit();
		
		mainFrame.sendMessage("Cancellata Mozzarella Prodotta.", MainFrame.OK_MESSAGE);
		
		
		DefaultTableModel dtm = (DefaultTableModel) ((RMozzarellaPnl)controlPnl).getJTable0().getModel();
		try{
			dtm.removeRow(selectedRow);
		}catch(Exception e ){}
		
		
		clearPnl();
		sqlSession.close();
	}
	
	public void insert (){
		Rmozzarella rMozzarella = new Rmozzarella();
		
		if(selectedRow!=-1 || ((RMozzarellaPnl)controlPnl).getJTable0().getModel().getRowCount()!=0){
			
			rMozzarella = (Rmozzarella)this.objList.get(this.selectedRow);
		}
		
		Integer dataStart = null;
		Integer dataStop = null;
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
		
		try{
			String tempStart = sdf.format( ((RMozzarellaPnl)controlPnl).getJXDatePicker2().getDate());
			tempStart = tempStart.concat("01");
			
			dataStart = new Integer(tempStart);
			
			String tempStop = sdf.format( ((RMozzarellaPnl)controlPnl).getJXDatePicker2().getDate());
			tempStop = tempStop.concat("31");
			
			dataStop = new Integer(tempStop);
			
			
			
		}catch(Exception e ){
			e.printStackTrace();
		}
		
		RmozzarellaExample rme = new RmozzarellaExample();
		
		rme.createCriteria().andDataproduzioneBetween(dataStart, dataStop);
		
		SqlSession sqlSession = MainController.getSqlSessionFactory().openSession();
		this.toBean(rMozzarella);
		if(selectedRow==-1 || ((RMozzarellaPnl)controlPnl).getJTable0().getModel().getRowCount()==0){

					
					
					sqlSession.getMapper(RmozzarellaMapper.class).insert(rMozzarella);
				
					sqlSession.commit();
					
					mainFrame.sendMessage("Inserita Mozzarella Prodotta.", MainFrame.OK_MESSAGE);
					
					
					
					objList = sqlSession.getMapper(RmozzarellaMapper.class).selectByExample(rme);
					
					DefaultTableModel dtm = (DefaultTableModel)((RMozzarellaPnl)controlPnl).getJTable0().getModel();
					
					String data4Table = "";
					
					try{
						SimpleDateFormat sdf4View = new SimpleDateFormat("dd/MM/yyyy");
						data4Table = sdf4View.format(SDF_4_DB.parse(rMozzarella.getDataproduzione().toString()));
					}catch(Exception e ){
						
					}
					
					String totale = "";
					Double serb1 = 0d;
					try{
						serb1 = Double.valueOf(rMozzarella.getSerb1());
						
					}catch(Exception e ){} 
					
					Double serb2 = 0d;
					try{
						serb2 = Double.valueOf(rMozzarella.getSerb2());
						
					}catch(Exception e ){} 
					
					Double serb3 = 0d;
					try{
						serb3 = Double.valueOf(rMozzarella.getSerb3());
						
					}catch(Exception e ){} 
					
					Double serb4 = 0d;
					try{
						serb4 = Double.valueOf(rMozzarella.getSerb4());
						
					}catch(Exception e ){} 
					
					Double totaleD = 0d;
			
					try{
						totaleD = serb1+serb2+serb3+serb4;
						totale = totaleD.toString();
					}catch(Exception e ){} 
					
					dtm.addRow(new String[]{data4Table, totale});

					clearPnl();
					
		
		}
		else{
					sqlSession.getMapper(RmozzarellaMapper.class).updateByPrimaryKey(rMozzarella);
				
					sqlSession.commit();
					mainFrame.sendMessage("Modificata Mozzarella Prodotta.", MainFrame.OK_MESSAGE);
					
					
					objList = sqlSession.getMapper(RmozzarellaMapper.class).selectByExample(rme);
					
					DefaultTableModel dtm = (DefaultTableModel)((RMozzarellaPnl)controlPnl).getJTable0().getModel();
					
					
					String data4Table = "";
					
					try{
						SimpleDateFormat sdf4View = new SimpleDateFormat("dd/MM/yyyy");
						data4Table = sdf4View.format(SDF_4_DB.parse(rMozzarella.getDataproduzione().toString()));
					}catch(Exception e ){
						
					}
					
					String totale = "";
					Double serb1 = 0d;
					try{
						serb1 = Double.valueOf(rMozzarella.getSerb1());
						
					}catch(Exception e ){} 
					
					Double serb2 = 0d;
					try{
						serb2 = Double.valueOf(rMozzarella.getSerb2());
						
					}catch(Exception e ){} 
					
					Double serb3 = 0d;
					try{
						serb3 = Double.valueOf(rMozzarella.getSerb3());
						
					}catch(Exception e ){} 
					
					Double serb4 = 0d;
					try{
						serb4 = Double.valueOf(rMozzarella.getSerb4());
						
					}catch(Exception e ){} 
					
					Double totaleD = 0d;
			
					try{
						totaleD = serb1+serb2+serb3+serb4;
						totale = totaleD.toString();
					}catch(Exception e ){} 
					
					dtm.setValueAt(data4Table,selectedRow,0);
					dtm.setValueAt(totale,selectedRow,1);

					clearPnl();
					
					
		}
		sqlSession.close();
	}
	
	public RMozzarellaPnl getMainPanel(){
		
			
		if( controlPnl==null){
			 controlPnl = new  RMozzarellaPnl(this);

		
	     ButtonGroup bg0 = new ButtonGroup();
	     bg0.add(((RMozzarellaPnl)controlPnl).getJRadioButton0());
	     bg0.add(((RMozzarellaPnl)controlPnl).getJRadioButton1());
	     
	     ButtonGroup bg1 = new ButtonGroup();
	     bg1.add(((RMozzarellaPnl)controlPnl).getJRadioButton2());
	     bg1.add(((RMozzarellaPnl)controlPnl).getJRadioButton3());
	     bg1.add(((RMozzarellaPnl)controlPnl).getJRadioButton4());
	     
	     
	     ButtonGroup bg2 = new ButtonGroup();
	     bg2.add(((RMozzarellaPnl)controlPnl).getJRadioButton5());
	     bg2.add(((RMozzarellaPnl)controlPnl).getJRadioButton6());
			 
	     JXTable theTable =  ((RMozzarellaPnl)controlPnl).getJTable0();
		 theTable.addHighlighter(HighlighterFactory.createAlternateStriping(Color.getHSBColor(229,229,229), Color.getHSBColor(208, 208, 208))); 
		
		 BasicController.tableDocumentListener.addTableListener( ((RMozzarellaPnl)controlPnl).getJTextField18(),  ((RMozzarellaPnl)controlPnl).getJTable0());
		 
		 theTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		 
		 ControlDocumentListener cdl = BasicController.controlDocumentListener;
		
		 ArrayList<JButton> listButton = new ArrayList<JButton>();
		 listButton.add( ((RMozzarellaPnl)controlPnl).getJButton2());
		 listButton.add( ((RMozzarellaPnl)controlPnl).getJButton4());
		
		 
		 ArrayList<JTextField> listMandatory = new ArrayList<JTextField>();
		
		 
		 ArrayList<JTextField> listNumeric = new ArrayList<JTextField>();
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField0());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField1());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField2());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField3());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField4());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField6());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField7());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField8());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField9());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField10());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField11());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField12());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField13());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField14());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField15());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField16());
		 listNumeric.add(((RMozzarellaPnl)controlPnl).getJTextField17());
		
		
		 
		 
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField0(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField1(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField2(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField3(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField4(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField6(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField7(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField8(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField9(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField10(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField11(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField12(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField13(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField14(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField15(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField16(), listButton, listMandatory, listNumeric);
		 cdl.addControlElement(ControlDocumentListener.NUMBER_FIELD,  ((RMozzarellaPnl)controlPnl).getJTextField17(), listButton, listMandatory, listNumeric);
		 
		}
		
		
		clearPnl();
		onDateSelect();
		return  ((RMozzarellaPnl)controlPnl);
	}

	@Override
	public List<? extends Object> getList4Print() {
		List<Rmozzarella> outList = new ArrayList<Rmozzarella>();
		if(selectedRow!=-1){
			outList.add((Rmozzarella)this.objList.get(selectedRow));
		}
		
		return outList;
	}

	@Override
	public String getControllerCode() {
		return R_MOZZARELLA;
	}

	@Override
	public void clearPnl() {
		RMozzarellaPnl rmozzarellaPnl  = (RMozzarellaPnl)controlPnl;
		
		rmozzarellaPnl.getJXDatePicker0().setDate(new Date());
		rmozzarellaPnl.getJXDatePicker1().setDate(new Date());
		rmozzarellaPnl.getJXDatePicker2().setDate(new Date());
		
		rmozzarellaPnl.getJTextField0().setText("");
		rmozzarellaPnl.getJTextField1().setText("");
		rmozzarellaPnl.getJTextField2().setText("");
		rmozzarellaPnl.getJTextField3().setText("");
		rmozzarellaPnl.getJTextField4().setText("");
		rmozzarellaPnl.getJTextField5().setText("");
		rmozzarellaPnl.getJTextField6().setText("");
		rmozzarellaPnl.getJTextField7().setText("");
		rmozzarellaPnl.getJTextField8().setText("");
		rmozzarellaPnl.getJTextField9().setText("");
		rmozzarellaPnl.getJTextField10().setText("");
		rmozzarellaPnl.getJTextField11().setText("");
		rmozzarellaPnl.getJTextField12().setText("");
		rmozzarellaPnl.getJTextField13().setText("");
		rmozzarellaPnl.getJTextField14().setText("");
		rmozzarellaPnl.getJTextField15().setText("");
		rmozzarellaPnl.getJTextField16().setText("");
		rmozzarellaPnl.getJTextField17().setText("");
		
		rmozzarellaPnl.getJTextField18().setText("");
		
		rmozzarellaPnl.getJRadioButton0().setSelected(true);
		
		rmozzarellaPnl.getJRadioButton2().setSelected(true);
		
		rmozzarellaPnl.getJRadioButton5().setSelected(true);
		
		rmozzarellaPnl.getJCheckBox0().setSelected(false);
		rmozzarellaPnl.getJCheckBox1().setSelected(false);
	}
	
	
	
	public void fromBean(Rmozzarella rmozzarella) {
		RMozzarellaPnl rmozzarellaPnl  = (RMozzarellaPnl)controlPnl;
		
		try{
			rmozzarellaPnl.getJXDatePicker0().setDate(SDF_4_DB.parse(Integer.valueOf(rmozzarella.getDataproduzione()).toString()));
		}catch(Exception e ){}
		
		try{
			rmozzarellaPnl.getJXDatePicker1().setDate(SDF_4_DB.parse(Integer.valueOf(rmozzarella.getScadenza()).toString()));
		}catch(Exception e ){}
		
		
		try{
			rmozzarellaPnl.getJTextField0().setText(rmozzarella.getSerb1().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField1().setText(rmozzarella.getSerb2().trim());
		}catch(Exception e ){}
		try{	
			rmozzarellaPnl.getJTextField2().setText(rmozzarella.getLotto().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField3().setText(rmozzarella.getSerb3().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField4().setText(rmozzarella.getSerb4().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField5().setText(rmozzarella.getValvoladerivflusso().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField6().setText(rmozzarella.getPast0().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField7().setText(rmozzarella.getPast1().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField8().setText(rmozzarella.getTempuscitapastorizzatore().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField9().setText(rmozzarella.getAciditasieroin().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField10().setText(rmozzarella.getLottosieroin().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField11().setText(rmozzarella.getCaglio().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField12().setText(rmozzarella.getAciditasieroliquidogov().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField13().setText(rmozzarella.getConcentrsaleliqgov().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField14().setText(rmozzarella.getLottoacidolattico().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField15().setText(rmozzarella.getLottoacidocitrico().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField16().setText(rmozzarella.getLottosale().trim());
		}catch(Exception e ){}
		try{
			rmozzarellaPnl.getJTextField17().setText(rmozzarella.getLottoimballoprimario().trim());
		}catch(Exception e ){}
				
		
		rmozzarellaPnl.getJRadioButton0().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton0().setSelected(rmozzarella.getNonuffindenne().booleanValue());
		}catch(Exception e ){}
		
		
		rmozzarellaPnl.getJRadioButton1().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton1().setSelected(!rmozzarella.getNonuffindenne().booleanValue());
		}catch(Exception e ){}
		
		
		rmozzarellaPnl.getJRadioButton2().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton2().setSelected(rmozzarella.getBusta().booleanValue());
		}catch(Exception e ){}
		
		rmozzarellaPnl.getJRadioButton3().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton3().setSelected(rmozzarella.getVaschetta().booleanValue());
		}catch(Exception e ){}
		
		rmozzarellaPnl.getJRadioButton4().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton4().setSelected(rmozzarella.getCartapergamena().booleanValue());
		}catch(Exception e ){}
		
		rmozzarellaPnl.getJRadioButton5().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton5().setSelected(rmozzarella.getPuntovendita().booleanValue());
		}catch(Exception e ){}
		
		rmozzarellaPnl.getJRadioButton6().setSelected(false);
		try{
			rmozzarellaPnl.getJRadioButton6().setSelected(rmozzarella.getVenditaesterna().booleanValue());
		}catch(Exception e ){}
		
		
		rmozzarellaPnl.getJCheckBox0().setSelected(false);
		try{
			rmozzarellaPnl.getJCheckBox0().setSelected(rmozzarella.getAcidolattico().booleanValue());
		}catch(Exception e ){}
	
		
		rmozzarellaPnl.getJCheckBox1().setSelected(false);
		try{
			rmozzarellaPnl.getJCheckBox1().setSelected(rmozzarella.getAcidocitrico().booleanValue());
		}catch(Exception e ){}
		
	}
	
	
	
	public void toBean(Rmozzarella rmozzarella) {
		RMozzarellaPnl rmozzarellaPnl  = (RMozzarellaPnl)controlPnl;
		
		try{
			rmozzarella.setDataproduzione(Integer.valueOf(SDF_4_DB.format(rmozzarellaPnl.getJXDatePicker0().getDate())));
		}catch(Exception e ){}
		
		try{
			rmozzarella.setScadenza(Integer.valueOf(SDF_4_DB.format(rmozzarellaPnl.getJXDatePicker1().getDate())));
		}catch(Exception e ){}
		
		
		try{
			rmozzarella.setSerb1(rmozzarellaPnl.getJTextField0().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setSerb2(rmozzarellaPnl.getJTextField1().getText().trim());
		}catch(Exception e ){}
		
		try{	
			rmozzarella.setLotto(rmozzarellaPnl.getJTextField2().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setSerb3(rmozzarellaPnl.getJTextField3().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setSerb4(rmozzarellaPnl.getJTextField4().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setValvoladerivflusso(rmozzarellaPnl.getJTextField5().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setPast0(rmozzarellaPnl.getJTextField6().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setPast1(rmozzarellaPnl.getJTextField7().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setTempuscitapastorizzatore(rmozzarellaPnl.getJTextField8().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setAciditasieroin(rmozzarellaPnl.getJTextField9().getText().trim());
		}catch(Exception e ){}
	
		try{
			rmozzarella.setLottosieroin(rmozzarellaPnl.getJTextField10().getText().trim());
		}catch(Exception e ){}
	
		try{
			rmozzarella.setCaglio(rmozzarellaPnl.getJTextField11().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setAciditasieroliquidogov(rmozzarellaPnl.getJTextField12().getText().trim());
		}catch(Exception e ){}

		try{
			rmozzarella.setConcentrsaleliqgov(rmozzarellaPnl.getJTextField13().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setLottoacidolattico(rmozzarellaPnl.getJTextField14().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setLottoacidocitrico(rmozzarellaPnl.getJTextField15().getText().trim());
		}catch(Exception e ){}
	
		try{
			rmozzarella.setLottosale(rmozzarellaPnl.getJTextField16().getText().trim());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setLottoimballoprimario(rmozzarellaPnl.getJTextField17().getText().trim());
		}catch(Exception e ){}
				
		
		
		try{
			rmozzarella.setNonuffindenne(rmozzarellaPnl.getJRadioButton0().isSelected());
		}catch(Exception e ){}
		
		
		
		try{
			rmozzarella.setBusta(rmozzarellaPnl.getJRadioButton2().isSelected());
		}catch(Exception e ){}
		
	
		try{
			rmozzarella.setVaschetta(rmozzarellaPnl.getJRadioButton3().isSelected());
		}catch(Exception e ){}
		
		try{
			rmozzarella.setCartapergamena(rmozzarellaPnl.getJRadioButton4().isSelected());
		}catch(Exception e ){}
		
	
		try{
			rmozzarella.setPuntovendita(rmozzarellaPnl.getJRadioButton5().isSelected());
		}catch(Exception e ){}
		
		
		try{
			rmozzarella.setVenditaesterna(rmozzarellaPnl.getJRadioButton6().isSelected());
		}catch(Exception e ){}
		
		
	
		try{
			rmozzarella.setAcidolattico(rmozzarellaPnl.getJCheckBox0().isSelected());
		}catch(Exception e ){}
	
		
		
		try{
			rmozzarella.setAcidocitrico(rmozzarellaPnl.getJCheckBox1().isSelected());
		}catch(Exception e ){}
		
	}
	
	
	
	
	
}
